<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>登录</title>
	<meta name="description" content="登录">
	<meta name="keywords" content="登录">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="renderer" content="webkit">
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="icon" type="image/png" href="assets/i/favicon.png">
	<link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
	<meta name="apple-mobile-web-app-title" content="Amaze UI" />
	<link rel="stylesheet" href="assets/css/amazeui.min.css" />
	<link rel="stylesheet" href="assets/css/amazeui.datatables.min.css" />
	<link rel="stylesheet" href="assets/css/app.css">
	<script src="assets/js/jquery.min.js"></script>
	<script type="text/javascript" src="assets/js/jquery.cookie.js"></script>
</head>
<body data-type="login">
	<script src="assets/js/theme.js"></script>
	<div class="am-g tpl-g">
		<!-- 风格切换 -->
		<div class="tpl-skiner">
			<div class="tpl-skiner-toggle am-icon-cog">
			</div>
			<div class="tpl-skiner-content">
				<div class="tpl-skiner-content-title">
					选择主题
				</div>
				<div class="tpl-skiner-content-bar">
					<span class="skiner-color skiner-white" data-color="theme-white"></span>
					<span class="skiner-color skiner-black" data-color="theme-black"></span>
				</div>
			</div>
		</div>
		<div class="tpl-login">
			<div class="tpl-login-content">
				<div class="tpl-login-logo">
				</div>
				<form class="am-form tpl-form-line-form">
					<div class="am-form-group">
						<input type="text" class="tpl-form-input" id="username" name="username" placeholder="请输入账号">
					</div>

					<div class="am-form-group">
						<input type="password" class="tpl-form-input" id="password" name="password" placeholder="请输入密码">
					</div>

					<!--                    <div class="am-form-group">
					<select name="roleid" class="tpl-form-select">
						<option value="考试者">考试者</option>
						<option value="管理员">管理员</option>
					</select>
				</div>-->
					<div class="am-form-group tpl-login-remember-me">
						<input id="remember-me" type="checkbox">
						<label for="remember-me">记住密码</label>
					</div>
					<div class="am-form-group">
						<button type="button" class="am-btn am-btn-primary  am-btn-block tpl-btn-bg-color-success  tpl-login-btn">登陆</button>
					</div>
				</form>
			</div>
		</div>
	</div>
	<script src="assets/js/amazeui.min.js"></script>
	<script src="assets/js/app.js"></script>
	<script>
		//登录操作并设置cookie
		$(document).ready(function() {
				$(".tpl-login-btn").click(function() {
					$.ajax({
						url: localApi + "/Admin/login",
						type: 'POST',
						async:false,
						data: {
							apikey: '1',
							username: $("#username").val(),
							userpass: $("#password").val()
						},
						beforeSend:function(XMLHttpRequest) {	
							
						},
						success: function(result) {
//						    console.log(result.data);
							if(result.msg == "success") {
								var currentUser = new Object();
								currentUser.username = result.data.username;
								currentUser.userpass = result.data.userpass;
								currentUser.id = result.data.id;
								$.cookie("currentUser", currentUser, {
									expires: 1,
									path: '/' + webName
								})
								$.cookie('username', $("#username").val(), {
									expires: 1,
									path: '/' 
								})
								$.cookie('id', currentUser.id, {
									expires: 1,
									path: '/' + webName
								})
								alert("登录成功");
								$.cookie('userInfo', result.data.ticket, {
									domain: 'texam.qingke.me',
									path: '/'
								});
								$.cookie('adminid', result.data.id, {
									domain: 'texam.qingke.me',
									path: '/'
								});
								window.location.href = "index.html";
							} else {
								alert("账号密码错误");
							}
						}
					});

				});
			});
	</script>
</body>
</html>